<#include "${ftl_skin}/common/header.ftl">
<#include "${ftl_skin}/common/js.ftl">

<style>
    .module-title {
        padding: 10px 20px;
        display: block;
        font-size: 14px;
        background-color: #fff;
        border-top: 4px solid #e7eaec;
        font-weight: bold;
        cursor: pointer;
    }

    .cert_send_addr_detail_box,
    .business_deadline_detail_box {
        opacity: 0;
    }

    .sample_bill_box {
        display: none;
    }

    .cost-total {
        margin-bottom: 20px;
    }

    .bs-item-name {
        width: 100%;
    }

    .bs-cost-standard {
        width: 70px !important;
    }

    .bs-cost-actual {
        width: 70px !important;
    }

    .bs-discount {
        width: 40px !important;
    }

    .bs-remark {
        width: 210px !important;
    }

    .input-group-btn {
        padding-bottom: 15px;
    }

    .billing, .preview {
        padding: 10px 20px !important;
        font-size: 16px;
    }
</style>


<style>
    .ibox-sru .float-e-margins { border-radius: 5px; }
    .ibox-sru .stat-percent { margin-top: 10px; font-size: 16px;  }
    .ibox-sru h1.no-margins { font-size: 35px; }
    .bg-green { background-color: #127e68; }
    .bg-blue-green { background-color: #19a0a1; }
    .bg-orange { background-color: #f8ac59; }
    h2 { font-family: "微软雅黑"; font-size: 20px; }
    .ibox-search dt { margin: 3px 15px 0 0; float: left; font-size: 20px; font-family: "微软雅黑"; font-weight: normal; }
    .ibox-search .input-group { padding: 0 20% 0 0; }
    .ibox-search .input-group .form-control { height: 38px; line-height: 38px; border-radius: 3px; font-size: 18px; font-family: "微软雅黑"; }
    .ibox-search .input-group .input-group-btn .btn { padding: 0 17px; margin: 0 0 0 10px; height: 36px; line-height: 35px; border-radius: 3px; font-size: 18px; font-family: "微软雅黑"; }
    .btn-circle { margin-left: 8px;  width: 18px; height: 18px; padding: 0; line-height: 18px; }
</style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content">
    <!--月收入-->
    <div class="row ibox-sru">
        <div class="col-sm-3">
            <div class="ibox float-e-margins bg-green">
                <div class="ibox-title">
                    <h2>待收检</h2>
                </div>
                <div class="ibox-content">
                    <div class="stat-percent font-bold">9月</div>
                    <h1 class="no-margins daishoujian">0</h1> </div>
            </div>
        </div>
        <div class="col-sm-3">
            <div class="ibox float-e-margins bg-blue">
                <div class="ibox-title">
                    <h2>待检测</h2>
                </div>
                <div class="ibox-content">
                    <div class="stat-percent font-bold">9月</div>
                    <h1 class="no-margins daijiance">0</h1> </div>
            </div>
        </div>
        <div class="col-sm-3">
            <div class="ibox float-e-margins bg-blue-green">
                <div class="ibox-title">
                    <h2>待复核</h2>
                </div>
                <div class="ibox-content">
                    <div class="stat-percent font-bold">9月</div>
                    <h1 class="no-margins daifuhe">0</h1> </div>
            </div>
        </div>
        <div class="col-sm-3">
            <div class="ibox float-e-margins bg-orange">
                <div class="ibox-title">
                    <h2>待签发</h2>
                </div>
                <div class="ibox-content">
                    <div class="stat-percent font-bold">9月</div>
                    <h1 class="no-margins daiqianfa">0</h1> </div>
            </div>
        </div>
    </div>
    <!--月收入 end-->
    <div class="row">
        <div class="col-sm-6">
            <dl class="ibox float-e-margins ibox-search">
                <dt>快速收检</dt>
                <dd class="input-group">
                    <input class="form-control" placeholder="请输入证书编号" value="" type="text" id="shouJian" onkeydown="javascript:if (event.keyCode==13){shouJian();return false;}">
                    <span class="input-group-btn"> 
                    <button type="button" onclick="shouJian()" class="btn btn-primary">确定</button>
                </span>
                </dd>
            </dl>
        </div>
        <div class="col-sm-6">
            <dl class="ibox float-e-margins ibox-search">
                <dt>快速审批</dt>
                <dd class="input-group">
                    <input class="form-control" placeholder="请输入证书编号" value="" type="text" id="shenPi" onkeydown="javascript:if (event.keyCode==13){shenPi();return false;}">
                    <span class="input-group-btn"> 
                    <button type="button" onclick="shenPi()" class="btn btn-primary">确定</button>
                </span>
                </dd>
            </dl>
        </div>
    </div>
    <div class="row">
        <!--代办列表-->
        <div class="col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>代办列表</h5>
                    <span class="label label-primary btn-circle">0</span>
                </div>
                <div class="ibox-content ibox-search">
                    <div class="input-group">
                        <input class="form-control" placeholder="请输入样品编码" value="" type="text">
                        <span class="input-group-btn"> 
                <button type="button" onclick="javascript:search()" class="btn btn-primary">确定</button>
            </span>
                    </div>
                </div>
            </div>
        </div>
        <!--代办列表 end-->
        <!--消息列表-->
        <div class="col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>消息列表</h5>
                </div>
                <div class="ibox-content" style="padding:8px;height:500px;">
                    <iframe src="/HFMessage/view/message/simplelist.ftl" id="myIframe" style="border: none;margin: 0px;">
                    </iframe>
                </div>
            </div>
        </div>
        <!--消息中心 end-->
    </div>
</div>
<script src="../skin/green/js/jquery.min.js?v=20170524-002"></script>
<script src="../skin/green/js/bootstrap.min.js?v=20170524-002"></script>
<script src="../skin/green/js/plugins/metisMenu/jquery.metisMenu.js?v=20170524-002"></script>
<script src="../skin/green/js/plugins/slimscroll/jquery.slimscroll.min.js?v=20170524-002"></script>
<script src="../skin/green/js/plugins/layer/layer.min.js?v=20170524-002"></script>
<script src="../skin/green/js/hplus.min.js?v=20170524-002"></script>
<script type="text/javascript" src="../skin/green/js/contabs.min.js?v=20170524-002"></script>

<!-- <script src="../skin/green/js/plugins/pace/pace.min.js?v=20170524-002"></script> -->

<script src="../skin/green/js/content.min.js?v=1.0.0"></script>

<!-- 表格 -->
<script src="../skin/green/js/plugins/bootstrap-table/bootstrap-table.min.js?v=20170524-002"></script>
<script src="../skin/green/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js?v=20170524-002"></script>
<script src="../skin/green/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js?v=20170524-002"></script>
<script src="../skin/green/js/plugins/bootstrap-table/bootstrap-table-resizable.js?v=20170524-002"></script>
<script src="../skin/green/js/plugins/bootstrap-table/colResizable-1.5.source.js?v=20170524-002"></script>

<!-- 友好提示框 -->
<script src="../skin/green/js/plugins/sweetalert/sweetalert.min.js?v=20170524-002"></script>

<!-- 广播提示信息 -->
<script src="../skin/green/js/plugins/toastr/toastr.min.js?v=20170524-002"></script>

<!-- 通用方法 -->
<script type="text/javascript" src="../common/js/js_func.js?v=20170524-002"></script>

<!-- md5处理方法 -->
<Script type="text/javascript" src="../common/tools/md5.js?currentTime="></Script>

<!-- contextmenu菜单工具 -->
<Script type="text/javascript" src="../skin/green/hongfeng/js/jquery.contextmenu.r2.js?currentTime="></Script>

<!-- 弹窗 -->
<script type="text/javascript" src="../common/tools/artdialog/dialog-plus-min.js"></script>

<!-- 表单验证 -->
<!--
	<script type="text/javascript" src="../common/tools/validform/Validform_v5.3.2_min.js"></script>
	-->
<script type="text/javascript" src="../skin/green/js/plugins/validate/jquery.validate.min.js"></script>
<script type="text/javascript" src="../skin/green/js/plugins/validate/messages_zh.min.js"></script>

<!-- 分页查询方法 -->
<script type="text/javascript" src="../common/hfutils/HFPager.js?v=20170524-002"></script>
<!-- 表单提交等 ajax方法 -->
<script type="text/javascript" src="../common/hfutils/HFAjax.js?v=20170524-002"></script>
<!-- 日历控件 -->
<script src="../common/assets/scripts/layer/laydate/laydate.js"></script>
<script src="../skin/green/js/plugins/datapicker/bootstrap-datepicker.js"></script>

<!--<script type="text/javascript" src="../common/assets/scripts/My97DatePicker/WdatePicker.js"></script>-->

<script src="../skin/green/js/plugins/datapicker/bootstrap-datepicker.js"></script>
<!-- 编辑框 -->
<!-- <script src="../skin/green/js/plugins/summernote/summernote.min.js"></script>
    <script src="../skin/green/js/plugins/summernote/summernote-zh-CN.js"></script> -->

<script src="../skin/green/js/plugins/kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="../skin/green/js/plugins/kindeditor/zh-CN.js"></script>

<!-- Base64编码 -->
<script src="../common/tools/base64.js"></script>
<script src="../skin/green/js/base64.js"></script>

<!-- JS 模板引擎 -->
<script src="../skin/green/js/plugins/artTemplate/template.js"></script>

<!-- 上传文件插件 -->
<script src="../common/tools/yxAjaxUpload/ajaxfileupload.js"></script>
<script src="../common/tools/yxAjaxUpload/jquery.yxAjaxUpload.js"></script>
<script type="text/javascript">

    $(function() {
        initBSTable('bs-table', {});

        $("div.stat-percent.font-bold").text(new Date().getMonth()+1 +"月");     //当前月份

        $.ajax({
            "type":"POST",
            "url":"/HFLims/service/detectprod/detectProdCount.do?time="+new Date().getTime(),
//            "data":{"prodStatus":???},
            "success":function(backData,textStatus,ajax){
                backData = eval(backData);      //js对象
                $("h1.no-margins.daishoujian").text( backData[0]);
                $("h1.no-margins.daijiance").text( backData[1]);
                $("h1.no-margins.daifuhe").text( backData[2]);
                $("h1.no-margins.daiqianfa").text( backData[3]);
            }
        });

        var ifrm = $("#myIframe");
        ifrm.height(ifrm.parent().height());
        ifrm.width(ifrm.parent().width());
    });


    //格式化显示
    function operateFormatter(value, row, index) {
        return [
            '<a class="query" href="javascript:item_query(\'' + row.user_code + '\');" title="查看">',
            '<i class="glyphicon glyphicon-search"></i>',
            '</a>&nbsp;',
            '&nbsp;<a class="edit" href="javascript:item_edit(\'' + row.user_code + '\');" title="编辑">',
            '<i class="glyphicon glyphicon-edit"></i>',
            '</a>&nbsp;',
            '&nbsp;<a class="remove" href="javascript:item_del(\'' + row.user_code + '\');" title="删除">',
            '<i class="glyphicon glyphicon-remove"></i>',
            '</a>'
        ].join('');
    }


    //$("body").children("div:first-child").show();

    //表格请求响应方法(分页)
    function pagerTableResponseHandler(res) {
        if(res.state == 0){
            // alert(JSON.stringify(res.result.list));
            for(var i in res.result.list){	//转换一下ID的值，直接使用ID在某些地方不适用
                if(isSet(res.result.list[i].id)){
                    res.result.list[i].tableid = res.result.list[i].id;
                }else if(isSet(res.result.list[i].ID)){
                    res.result.list[i].tableid = res.result.list[i].ID;
                }else{
                    res.result.list[i].tableid = "noid";
                }
            }

            var json = {};
            json.total = res.result.total;
            json.rows = res.result.list;
            return json;
        }
        return [];
    }
    //表格请求响应方法(不分页)
    function tableResponseHandler(res) {
        if(res.state == 0){
            // alert(JSON.stringify(res.result.list));
            for(var i in res.result.list){	//转换一下ID的值，直接使用ID在某些地方不适用
                if(isSet(res.result.list[i].id)){
                    res.result.list[i].tableid = res.result.list[i].id;
                }else if(isSet(res.result.list[i].ID)){
                    res.result.list[i].tableid = res.result.list[i].ID;
                }else{
                    res.result.list[i].tableid = "noid";
                }
            }
            return res.result.list;
        }
        return [];
    }

    //初始化表格
    function initBSTable(tableid, data){

        /*var data = [
            {"tag_time":"2017-09-21 00:00:00","tag_title":"这是一个系统消息"},
            {"tag_time":"2017-09-21 00:00:00","tag_title":"这是一个系统消息"},
            {"tag_time":"2017-09-21 00:00:00","tag_title":"这是一个系统消息"},
            {"tag_time":"2017-09-21 00:00:00","tag_title":"这是一个系统消息"},
        ];*/

        $('#' + tableid).bootstrapTable({data:data});
        $('.bootstrap-table .btn-default').addClass('btn-outline');
    }

    //搜索表格
    function searchBSTable(tableid, formid){
        $('#' + tableid).bootstrapTable('refreshOptions',{pageNumber:1});
        $('#' + tableid).bootstrapTable('refresh', {query: $('#' + formid).serializeObject()});
    }

    //获取当前选中的行的值
    function getIdSelections(tableid) {
        return $.map($('#' + tableid).bootstrapTable('getSelections'), function (row) {
            if (row.id) {
                return row.id
            } else {
                return row.ID
            }
        });
    }
    //获取当前选中的行的某个值
    function getValSelections(tableid,colid) {
        return $.map($('#' + tableid).bootstrapTable('getSelections'), function (row) {
            var str = " var colval = row."+colid;
            eval(str);
            return colval
        });
    }

    //刷新表格
    function refreshBSTable(tableid){
        $('#' + tableid).bootstrapTable('refresh');	//刷新表格
    }

    function shouJian() {
        var cert_num = $("#shouJian").val();

        HFAjax("/HFLims/service/cert/getCertByCertNum.do", {cert_num: cert_num}, function(result){
            if(result) {
                var prodId = result.result.prod_id;
                var cert_status = result.result.cert_status;
                var showAccept = "false";
                var sign = "";
                if(result.result.busi_type == 0) {
                    sign = "assay";
                } else if(result.result.busi_type == 1) {
                    sign = "meas";
                }
                if(cert_status == 0) {
                    showAccept = "true";
                }
                openDialog("prodDetail", "检测样品详情", "/HFLims/view/detectprod"+sign+"/proddetail.do?" + $.param({
                    id: prodId,
                    showAccept: showAccept
                }), {}, 1200, getAutoHeight(), function () {

                });
            }
        });
    }

    /*

    BILLED(0, "已开单，待收检"),
	ACCEPTED(1, "已收检，待检测"),
	DETECTED(2, "已检测，待复核"),
	RECHECKED(3, "已复核，待签发"),
	SIGNED(4, "已签发，待打印"),
	PRINTED(5, "已打印，待签收"),
	RECEIPTED(6, "已签收，待发放"),
	GRANTED(7, "已发放，完成"),
	UNACCEPTED(-1, "已退检，待退回"),
	RETURNED(-2, "已退回");


    ASSAY(0, "质检"),
	MEAS(1, "计量");
     */
    function shenPi() {
        var cert_num = $("#shenPi").val();

        HFAjax("/HFLims/service/cert/getCertByCertNum.do", {cert_num: cert_num}, function(result){
            if(result) {
                var prodId = result.result.prod_id;
                var certId = result.result.id;
                var cert_status = result.result.cert_status;
                var sign = "";
                var url = '';
                if(result.result.busi_type == 0) {
                    sign = "assay";
                } else if(result.result.busi_type == 1) {
                    sign = "meas";
                }

                if(cert_status < 2) {
                    alert("样品未检测")
                } else if(cert_status == 2) {
                    url = '/HFLims/view/detectprod' + sign + '/originaldatarecheck.do?';
                } else if(cert_status == 4) {
                    url = '/HFLims/view/detectprod' + sign + '/certrepealsign.do?';
                } else if(cert_status == 3) {
                    url = '/HFLims/view/detectprod' + sign + '/certsign.do?';
                } else {
                    url = '/HFLims/view/detectprod' + sign + '/certrepealsign.do?';
                }
                setNewIframe("证书信息", url + $.param({
                    prod_id: prodId,
                    cert_id: certId,
                }));
            }
        });

    }

    //在新标签打开
    function setNewIframe(title,url){
        $('#newIframe', window.parent.document).text(title);
        $('#newIframe', window.parent.document).attr('href',url);
        parent.toNewIframe();
    }

    function getAutoHeight() {
        return $(window).height() * 0.90;
    }

</script>

<#include "${ftl_skin}/common/footer.ftl">
